/**
 * @Title: UserAccountDao.java
 * @Description:
 * @author zsw
 * <p>
 * Copyright(C) 2018-2019    NPlus
 * Company:   无锡核心信息科技有限公司
 * @version V2.0.0
 * @Date: 13:11 2020/4/2
 * <p>
 * 修改历史:
 * Date                 Author        Version        Description
 * -----------------------------------------------------------------------------------
 * 13:11 2020/4/2       zsw        2.0.0           初始化版本
 */
package com.example.dataTransactionDao;

import com.example.dataTransaction.SingleThreadConnectionHolder;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * 第四步
 */
public class UserAccountDao {
    private DataSource dataSource;

    public UserAccountDao(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public void buy() throws SQLException {
        Connection connection = SingleThreadConnectionHolder.getConnection(dataSource);
        System.out.println("当前用户购买线程：" + Thread.currentThread().getName() + "使用管道hashcode:" + connection.hashCode());
    }
}
